<template>
	<view class="x-modal x-flex-column-center" @tap.stop="closeModel">
		<u-popup mode="bottom" v-model="props.modelValue">
			<view class="middleContent" @tap.stop="">
				<view class="titleRow x-flex-row-between-center">
					<text class="tit">支付</text>
					<view class="leftClose x-flex-row-center" @tap="closeModel">
						<u-icon name="close" size="20"></u-icon>
					</view>
				</view>
				<view class="moneyArea x-flex-column-center">
					<text class="monDes">所需支付金额</text>
					<text class="monNum">{{ money }}</text>
				</view>
				<view class="wxAndAlis">
					<view class="row x-flex-row-between-center" v-for="item in payList" :key="item.name"
						@click.stop="currentPayIndex = item.sign">
						<view class="left">
							<!-- http://api.dev.fahuren.com/assets/images/payment/wx.png -->
							<image style="width: 64rpx; height: 64rpx;" :src="item.imgUrl">
							</image>
						</view>
						<view class="center">
							{{ item.name }}
						</view>
						<view class="right" :class="currentPayIndex == item.sign ? 'markActive' : ''">
							<u-icon name="checkbox-mark" color="#fff" size="28"></u-icon>
						</view>
					</view>
				</view>
				<view class="des">
					我同意购买守则，我也同意支付以下所示的总金额(含服务费)。
				</view>
				<view class="footArea">
					<u-button type="primary" @click="emits('confirm', currentPayIndex)">
						<view class="pay">
							<text class="u-padding-right-10">确定订单</text>
							<text class="money">￥ {{ money }}</text>
						</view>
					</u-button>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script setup>
import {
	onMounted,
	ref,
	reactive
} from "vue";
import config from '@/js/config.js';

const props = defineProps({
	modelValue: {
		type: Boolean,
		default: false
	},
	'confirmText': {
		type: String,
		default: '确定'
	},
	'cancelText': {
		type: String,
		default: '取消'
	},
	title: {
		type: String,
		default: '标题'
	},
	money: {
		type: [String, Number],
		default: 0
	}
})
const emits = defineEmits(['update:modelValue', 'confirm', 'cancel'])
const modalShow = ref(false)
const payList = reactive([
	{
		name: '微信支付',
		imgUrl: `${config.imgPath}/payment/wx.png`,
		sign: 'wxpay'
	},
	// #ifdef APP-PLUS
	{
		name: '支付宝支付',
		imgUrl: `${config.imgPath}/payment/zfb.png`,
		sign: 'alipay'
	}
	// #endif
])
const currentPayIndex = ref('wxpay')

function closeModel() {
	emits('update:modelValue', false)
}
</script>

<style lang="scss">
.markActive {
	background-color: #2979ff;
	border-color: #2979ff !important;
}

.x-modal {
	z-index: 9999;

	.middleContent {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
		padding: 28rpx 48rpx;

		.titleRow {
			.tit {
				font-size: 34rpx;
				font-weight: bold;
				color: #333333;
			}

			.leftClose {
				width: 36rpx;
				height: 36rpx;
				background: rgba(0, 0, 0, 0.06);
				border-radius: 50%;
			}
		}

		.moneyArea {
			height: 216rpx;
			background: rgba(249, 89, 77, 0.06);
			margin: 24rpx 0;
			font-weight: bold;

			.monDes {
				font-size: 28rpx;
				color: #333333;
				line-height: 42rpx;
			}

			.monNum {
				font-size: 56rpx;
				color: #F9594D;
				line-height: 70rpx;

				&::before {
					content: '￥';
					font-size: 36rpx;
					font-weight: bold;
					color: #F9594D;
					line-height: 42rpx;
				}
			}
		}

		.wxAndAlis {
			.row {
				border-bottom: 1rpx solid #F6F6F6;

				.left {
					margin-right: 16rpx;
				}

				.center {
					flex: 1;
					padding: 30rpx 0;
				}

				.right {
					width: 40rpx;
					height: 40rpx;
					border-radius: 50%;
					border: solid 4rpx #909399;
					text-align: center;
					line-height: 36rpx;
				}
			}
		}

		.des {
			font-size: 26rpx;
			font-weight: 500;
			color: #999999;
			line-height: 39rpx;
			padding: 32rpx 0;
		}

		.footArea {
			border-top: 1rpx solid rgba(0, 0, 0, 0.06);
			padding: 16rpx 0;

			.pay {
				font-size: 28rpx;
				font-weight: bold;
				color: #FFFFFF;
				line-height: 33rpx;
			}
		}

	}
}
</style>